<?php

namespace App\Http\Controllers\Web;

use App\Handlers\ArticleAnchorsHandler;
use App\Http\Controllers\Controller;
use App\Models\Anchor;
use App\Repositories\NewRepository;
use App\Repositories\ProductRepository;
use App\Services\ArticleService;
use Illuminate\Http\Request;

class NewsController extends Controller
{
    private $newRepository;

    public function __construct(NewRepository $newRepository)
    {

        $this->newRepository = $newRepository;
    }

    public function index(Request $request){

        $news = $this->newRepository->paginate(6);


        return template('news',compact('news'));
    }

    public function show($id){
        $new = $this->newRepository->find($id);

        $newNews = $this->newRepository->newNews();

        $next = $this->newRepository->getNextArticle($id);
        $prev = $this->newRepository->getPrevArticle($id);

        return template('news-desc',compact('new','newNews','next','prev'));
    }
}
